package cn.zhaozhiqi.controller.app;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.zhaozhiqi.pojo.dto.AddCarDto;
import cn.zhaozhiqi.pojo.dto.CustomerRegisterDto;
import cn.zhaozhiqi.result.JSONResult;
import cn.zhaozhiqi.service.ICustomerCarService;
import cn.zhaozhiqi.service.ICustomerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Tag(name = "乘客注册",description = "乘客注册")
@RestController
@RequestMapping("app/customer")
public class AppCustomerController {

    @Autowired
    public ICustomerService customerService;
    @Autowired
    private ICustomerCarService carService;

    @Operation( summary= "customer",description = "使用post注册一个新的司机用户")
    @Parameter(name = "传入的customerRegisterDto",description = "前端传入的信息，例如wx的code",required = true)
    @PostMapping("/resgister")
    @SaIgnore
    public JSONResult<Boolean> driverRegister(@RequestBody @Valid CustomerRegisterDto dto){
        return JSONResult.success(customerService.customerRegister(dto));
    }

    @Operation( summary= "添加车辆信息",description = "添加车辆信息接口")
    @Parameter(name = "AddCarDto",description = "AddCarDto",required = true)
    @PostMapping("/car/add")
    public JSONResult addCarMessage(@RequestBody @Valid AddCarDto dto){
        return JSONResult.success(carService.addCarMessage(dto));
    }

    @Operation( summary= "查询车辆信息",description = "查询车辆信息接口")
    @Parameter(name = "AddCarDto",description = "AddCarDto",required = true)
    @GetMapping("/car/list/current")
    public JSONResult searchCarList(){
        return JSONResult.success(carService.searchCarList());
    }

}
